#!/bin/bash

starttime=0
interval=$1

duration=$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$2" | cut -d '.' -f 1)
echo "=> 视频时长: $duration"
while [ $starttime -lt $duration ]; do
  ffmpeg -ss $starttime -i "$2" -n -vframes 1 -r 1 -lossless 0 "$3/$starttime.jpg" 2>&1 | grep ^Output
  starttime=$(($starttime + $interval))
done
